import bean.Person;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;

import java.util.List;

public class d4j {
    public static void main(String[] args) throws DocumentException {
        SAXReader saxReader = new SAXReader();
        Document read = saxReader.read(Class.class.getResourceAsStream("/person.xml"));

        Element rootElement = read.getRootElement();
        System.out.println(rootElement);

        List<Element> people = rootElement.elements("people");
        for (int i = 0; i < people.size(); i++) {
            System.out.println("=============================");
            Element x = people.get(i);
//            System.out.println(x);
            Element name = x.element("name");
            Element age = x.element("age");
            Element address = x.element("address");
            Element sex = x.element("sex");
            System.out.println(name.getText());
            System.out.println(age.getText());
            System.out.println(address.getText());
            System.out.println(sex.getText());

            System.out.println("=============================");

        }

        System.out.println(read);
    }
}
